const joi = require("joi");

// id验证
const id = joi.required();
// 姓名验证
const name = joi
  .string()
  .required()
  .pattern(/^[\u4e00-\u9fa5]/);
// 邮箱验证
const email = joi
  .string()
  .required()
  .pattern(/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/);
// 密码验证
const oldPassword = joi
  .string()
  .pattern(/^(?![0-9]+$)[a-z0-9]{1,50}$/)
  .min(6)
  .max(12)
  .required();
const newPassword = joi
  .string()
  .pattern(/^(?![0-9]+$)[a-z0-9]{1,50}$/)
  .min(6)
  .max(12)
  .required();

// 导出姓名验证
exports.name_limit = {
  body: {
    id,
    name,
  },
};
// 导出邮箱验证
exports.email_limit = {
  body: {
    id,
    email,
  },
};
// 导出密码验证
exports.password_limit = {
  body: {
    id,
    oldPassword,
    newPassword,
  },
};
exports.loginPassword_limit = {
  body: {
    id,
    newPassword,
  },
};
